package com.mediacloud.app.newsmodule.fragment.baoliao.activity;

import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.flyco.tablayout.SlidingTabLayout;
import com.mediacloud.app.assembly.adapter.CatalogContentFragmentAdapter;
import com.mediacloud.app.model.activity.BaseBackActivity;
import com.mediacloud.app.newsmodule.R;
import com.mediacloud.app.newsmodule.fragment.baoliao.frag.MyBaoLiaoListFragment;
import com.mediacloud.app.newsmodule.utils.AppThemeTabLayoutStyle;

import java.util.ArrayList;
import java.util.List;

public class MyBaoLiaoListActivity extends BaseBackActivity {

    private ViewPager mViewPager;
    private SlidingTabLayout mTabLayout;
    private List<String> titles;
    private ArrayList<Fragment> mFragmentList = new ArrayList<>();
    private boolean fromUserCenter;

    @Override
    public int getLayoutResID() {
        return R.layout.activity_my_bao_liao_list;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        fromUserCenter = getIntent().getBooleanExtra("fromUserCenter", false);
        mFragmentList = new ArrayList<>();
        mFragmentList.add(MyBaoLiaoListFragment.newInstance("2"));
        mFragmentList.add(MyBaoLiaoListFragment.newInstance("-1"));
//        mFragmentList.add(MyBaoLiaoListFragment.newInstance(4));
//        mFragmentList.add(MyBaoLiaoListFragment.newInstance(5));
        String title = "";
        try {
            title = getIntent().getStringExtra("title");
        } catch (Exception e) {
            e.printStackTrace();
        }
        setTitle(TextUtils.isEmpty(title) ?"线索爆料" : title);
        titles = new ArrayList<>();
        titles.add("已发布");
        titles.add("审核");
//        titles.add("审核通过");
//        titles.add("审核不通过");
        mViewPager = findViewById(R.id.mViewPager);
        mTabLayout = findViewById(R.id.mTabLayout);
        AppThemeTabLayoutStyle.setTabLayoutColor(this,mTabLayout);
        CatalogContentFragmentAdapter myPagerAdapter = new CatalogContentFragmentAdapter(getSupportFragmentManager(),mFragmentList)
        {
            @Nullable
            @Override
            public CharSequence getPageTitle(int position) {
                return titles.get(position);
            }
        };
        myPagerAdapter.needDestory=false;
        mViewPager.setAdapter(myPagerAdapter);
        mTabLayout.setViewPager(mViewPager);
    }

    /**
     * 不晓得那个哈要以哪个字段为准
     * 很有趣
     * @return
     */
   /* protected String getContent_show_top_color()
    {
        return AppFactoryGlobalConfig.getAppServerConfigInfo(this).getTop_color();
    }*/
    @Override
    protected boolean whenOfflineFinishPage() {
        return true;
    }

    @Override
    protected String getContent_show_top_color() {
        if (fromUserCenter){
            mTitileBar.setBackgroundColor(Color.WHITE);
            return "#333333";
        }else{
            return super.getContent_show_top_color();
        }

    }

    @Override
    public int getStatusBarColor() {
        if (fromUserCenter)
        return Color.WHITE;
        else return super.getStatusBarColor();
    }
}